import sys
import os

def resource_path(relative_path):
    """ 获取打包后资源的绝对路径 """
    if getattr(sys, 'frozen', False):  # 判断是否在打包环境中
        base_path = sys._MEIPASS
    else:
        base_path = os.path.abspath(".")
    return os.path.join(base_path, relative_path)
